import type { couponListItem } from '@/types/coupon'
import type { PageParams, PageResult } from '@/types/global'
import { request } from '@/utils/request'

// 领券中心
export const getCouponListApi = (data: PageParams) => {
  return request<PageResult<couponListItem[]>>({
    url: '/coupon/center',
    method: 'GET',
    data,
  })
}

// 领券操作
export const receiveCouponApi = (id: number) => {
  return request<{ id: number }>({
    url: '/coupon/receive',
    method: 'POST',
    data: {
      id,
    },
  })
}

// 我的优惠券
export const getMyCouponListApi = (
  data: PageParams & {
    status: string
  },
) => {
  return request<PageResult<couponListItem[]>>({
    url: '/userCoupon/list',
    method: 'GET',
    data,
  })
}
